Skip to content

fix: resolve false-positive rate limit and version bump to 0.1.15#212

Merged
leonvanzyl merged 3 commits intomasterfrom
fix/rate-limit-and-version-bump
Feb 23, 2026
Merged

fix: resolve false-positive rate limit and version bump to 0.1.15#212
leonvanzyl merged 3 commits intomasterfrom
fix/rate-limit-and-version-bump

Conversation

@leonvanzyl
Copy link
Collaborator

Summary

  • Fix false-positive rate limit detection and one-message-behind bug in chat sessions (assistant, spec, expand)
  • Remove client-side rate limit handling from UI hooks in favor of server-side handling
  • Version bump to 0.1.15

Test plan

  • Verify chat sessions no longer show false rate limit errors
  • Confirm assistant, spec creation, and expand project chats work correctly
  • Check version displays as 0.1.15

🤖 Generated with Claude Code

leonvanzyl and others added 3 commits February 23, 2026 13:00
… sessions

The Claude Code CLI v2.1.45+ emits a `rate_limit_event` message type that
the Python SDK v0.1.19 cannot parse, raising MessageParseError. Two bugs
resulted:

1. **False-positive rate limit**: check_rate_limit_error() matched
   "rate_limit" in the exception string "Unknown message type:
   rate_limit_event" via both an explicit type check and a regex fallback,
   triggering 15-19s backoff + query re-send on every session.

2. **One-message-behind**: The MessageParseError killed the
   receive_response() async generator, but the CLI subprocess was still
   alive with buffered response data. Catching and returning meant the
   response was never consumed. The next send_message() would read the
   previous response first, creating a one-behind offset.

Changes:

- chat_constants.py: check_rate_limit_error() now returns (False, None)
  for any MessageParseError, blocking both false-positive paths. Added
  safe_receive_response() helper that retries receive_response() on
  MessageParseError — the SDK's decoupled producer/consumer architecture
  (anyio memory channel) allows the new generator to continue reading
  remaining messages without data loss. Removed calculate_rate_limit_backoff
  re-export and MAX_CHAT_RATE_LIMIT_RETRIES constant.

- spec_chat_session.py, assistant_chat_session.py, expand_chat_session.py:
  Replaced retry-with-backoff loops with safe_receive_response() wrapper.
  Removed asyncio.sleep backoff, query re-send, and rate_limited yield.
  Cleaned up unused imports (asyncio, calculate_rate_limit_backoff,
  MAX_CHAT_RATE_LIMIT_RETRIES).

- agent.py: Added inner retry loop around receive_response() with same
  MessageParseError skip-and-restart pattern. Removed early-return that
  truncated responses.

- types.ts: Removed SpecChatRateLimitedMessage,
  AssistantChatRateLimitedMessage, and their union entries.

- useSpecChat.ts, useAssistantChat.ts, useExpandChat.ts: Removed dead
  'rate_limited' case handlers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@leonvanzyl leonvanzyl merged commit 472064c into master Feb 23, 2026
2 checks passed
@leonvanzyl leonvanzyl deleted the fix/rate-limit-and-version-bump branch February 23, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant